package org.apache.seatunnel.app.test;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class KafkaProducerService implements InitializingBean {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    public void sendMessage(String topic, String message) {
        kafkaTemplate.send(topic, message);
    }


    @Override
    public void afterPropertiesSet() throws Exception {

        for (int i = 0; i < 1000; i++) {
            sendMessage("myTopic", "message" + i);
        }

    }
}